package fr.norsys.mapper.console.web;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import uk.ltd.getahead.dwr.ExecutionContext;
import fr.norsys.mapper.console.exception.IdentifiantException;
import fr.norsys.mapper.console.model.ConsoleCst;
import fr.norsys.mapper.console.model.IdentifiantComponent;
import fr.norsys.mapper.console.service.IdentifiantService;
import fr.norsys.mapper.console.service.PropertyServiceImpl;

public class IdentifiantServiceDWR {
	private final static Log log = LogFactory.getLog(PropertyServiceImpl.class);

	private IdentifiantService identifiantService;

	IdentifiantServiceDWR() {
		super();
	}

	/**
	 * Action to save an IdentifiantComponent in the lis in session
	 * 
	 * @param identifiant
	 */
	public void save(IdentifiantComponent identifiant) {
		List identifiants = (List) ExecutionContext.get().getSession()
				.getAttribute(ConsoleCst.IDS_SESSION_BEAN);
		try {
			identifiantService.save(identifiant, identifiants);
		} catch (IdentifiantException e) {
			log.error(e);
		}
		ExecutionContext.get().getSession().setAttribute(ConsoleCst.IS_APPLICATION_MODIFIED,ConsoleCst.APPLICATION_MODIFIED);
	}

	public IdentifiantService getIdentifiantService() {
		return identifiantService;
	}

	public void setIdentifiantService(IdentifiantService identifiantService) {
		this.identifiantService = identifiantService;
	}
}
